/*******************************************************************************
 * Copyright (c) 2009 Brian Edginton and Aaron Getz.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Brian Edginton - initial API and implementation
 *     Aaron Getz
 *******************************************************************************/

package org.eclipse.mylyn.internal.eplanner.ui.wizard;

import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.mylyn.internal.eplanner.core.EPlannerCorePlugin;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.widgets.Composite;

public class EPlannerRepositorySettingsPage extends AbstractRepositorySettingsPage {
	
	private static final String TITLE = Messages.EplannerRepositorySettingsPage_Eplanner_Repository_Settings;
	private static final String DESCRIPTION = Messages.EplannerRepositorySettingsPage_EXAMPLE_HTTP_EXTREME_PLANNER_COM;

	public EPlannerRepositorySettingsPage(TaskRepository taskRepository) {
		super(TITLE, DESCRIPTION, taskRepository);
	}

	@Override
	protected void createAdditionalControls(Composite parent) {
		// TODO Implement this method to add additional controls
		// to the settings page.

	}

	@Override
	public String getConnectorKind() {
		return EPlannerCorePlugin.CONNECTOR_KIND;
	}

	@Override
	protected Validator getValidator(TaskRepository repository) {
		// TODO Extend org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.Validator
		// to create a class that validates data on the settings page.
		return null;
	}

	@Override
	protected boolean isValidUrl(String name) {
		if ((name.startsWith(URL_PREFIX_HTTPS) || name.startsWith(URL_PREFIX_HTTP)) && !name.endsWith("/")) { //$NON-NLS-1$
			try {
				new URL(name);
				return true;
			} catch (MalformedURLException e) {
			}
		}
		return false;
	}

}
